package com.leadingsoft.pwxk.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.leadingsoft.pwxk.converter.WaterDrainInfoConverter;
import com.leadingsoft.pwxk.dto.WaterDrainInfoDto;
import com.leadingsoft.pwxk.model.WaterDrainInfo;
import com.leadingsoft.pwxk.repository.WaterDrainInfoRepository;
import com.leadingsoft.pwxk.service.WaterDrainInfoService;

@Service
public class WaterDrainInfoServiceImpl implements WaterDrainInfoService {

	@Autowired
	private WaterDrainInfoRepository waterDrainInfoRepository;
	@Autowired
	private WaterDrainInfoConverter waterDrainInfoConverster;

	@Override
	public WaterDrainInfoDto get(String dataid) {
		List<WaterDrainInfo> findByDataid = waterDrainInfoRepository.findByDataid(dataid);
		return waterDrainInfoConverster.toDto(findByDataid == null ? null : findByDataid.get(0));
	}

	@Override
	public List<WaterDrainInfoDto> findByDataId(String dataid) {
		return waterDrainInfoConverster.toDto(waterDrainInfoRepository.findByDataid(dataid));
	}
}
